package com.jiao.service.impl;

import com.jiao.constants.Constants;
import com.jiao.domain.Result;
import com.jiao.domain.VO.LinkVo;
import com.jiao.domain.entity.Link;
import com.jiao.mapper.LinkMapper;
import com.jiao.service.LinkService;
import com.jiao.utils.BeanCopyUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 友链(Link)表服务实现类
 *
 * @author makejava
 * @since 2022-02-27 14:40:23
 */
@Service("linkService")
public class LinkServiceImpl extends ServiceImpl<LinkMapper, Link> implements LinkService {
    @Autowired
    LinkMapper linkMapper;

    public Result<List<LinkVo>> selectAllLinkList(){
        LambdaQueryWrapper<Link> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(Link::getStatus, Constants.List_STATUS_NORMAL);
        List<Link> links = linkMapper.selectList(queryWrapper);
        List<LinkVo> linkVos = BeanCopyUtils.copyBeanList(links, LinkVo.class);

        return Result.success(linkVos);
    }
}
